<!DOCTYPE html>
<html lang="en">


{include file="Public/head"}

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    {include file='Public:header'}
    {include file='Public:menu2'}



    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title  am-cf">优惠券列表</div>
                        </div>
                        <div class="widget-body  am-fr">


                            <!--筛选搜索-->
                            <form action="">
                                <table class="table">
                                    <a href="{:url('Coupon/coupon_info')}" class="btn btn-primary pull-right"><i class="fa fa-plus"></i>添加优惠券</a>
                                </table>
                            </form>
                        <div id="ajax_return">
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);"></td>
                                        <td class="text-center">优惠券名称</td>
                                        <td class="text-center">优惠券类型</td>
                                        <td class="text-center">面额</td>
                                        <td class="text-center">使用需满金额</td>
                                        <td class="text-center">发放总量</td>
                                        <td class="text-center">已发放数</td>
                                        <td class="text-center">已使用</td>
                                        <td class="text-center">使用截止日期</td>
                                        <td class="text-center">操作</td>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {volist name="lists" id="list"}
                                        <tr>
                                            <td class="text-center">
                                                <input type="checkbox" name="selected[]" value="6">
                                            </td>
                                            <td class="text-center">{$list.name}</td>
                                            <td class="text-center">{$coupons[$list['type']]}</td>
                                            <td class="text-center">{$list.money}</td>
                                            <td class="text-center">{$list.condition}</td>
                                            <td class="text-center">{$list.createnum}</td>
                                            <td class="text-center">{$list.send_num}</td>
                                            <td class="text-center">{$list.use_num}</td>
                                            <td class="text-center">{$list.use_end_time|date='Y-m-d',###}</td>
                                            <td class="text-center">
                                                <!--{if condition="$list['type'] eq 4"}-->
                                                    <!--<a href="{:url('Coupon/make_coupon',array('id'=>$list['id'],'type'=>$list['type']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="发放"><i class="fa fa-send"></i></a>-->
                                                    <!--{elseif condition="$list['type'] eq 1"/}-->
                                                    <!--<a href="javascript:void(0)" data-toggle="tooltip" title="发放" class="btn btn-info send_user" data-url="{:url('Coupon/send_coupon',array('cid'=>$list['id']))}"><i class="fa fa-send-o"></i></a>-->
                                                    <!--{else/}-->
                                                    <!--<a href="javascript:void(0)" data-toggle="tooltip" title="" class="btn btn-default disabled" data-original-title="查看"><i class="fa fa-send-o"></i></a>-->
                                                <!--{/if}-->
                                                <a href="{:url('Coupon/send_coupon',array('cid'=>$list['id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="发放"><i class="fa fa-eye"></i></a>
                                                <a href="{:url('Coupon/coupon_edit',array('id'=>$list['id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="编辑"><i class="fa fa-pencil"></i></a>
                                                <a data-url="{:url('Coupon/del_coupon',array('id'=>$list['id']))}" onclick="delfun(this)" href="javascript:;" data-toggle="tooltip" title="" class="btn btn-danger" data-original-title="删除"><i class="fa fa-trash-o"></i></a></td>
                                        </tr>
                                    {/volist}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                            <div class="am-u-lg-10 am-cf">

                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">
                                        {$lists->render()}
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
{include file='Public:script'}
<script>
    $('.send_user').click(function(){
        var url = $(this).attr('data-url');
        layer.open({
            type: 2,
            title: '发放优惠券',
            shadeClose: true,
            shade: 0.5,
            area: ['70%', '85%'],
            content: url,
        });
    });

    // 删除按钮
    function delfun(obj) {
        layer.confirm("确定删除？", {btn: ["确定","取消"], shade: 0.5}, function(){
            // 删除权限组
            $.post($(obj).attr('data-url'), function(res) {
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                    return false;
                }

                layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 1}, function() {
                    layer.closeAll('page');
                    location.reload();
                });
            });
        }, function () {});
    }

</script>
